package com.sk.skplanet.commute.actions;

import android.annotation.SuppressLint;

import com.sk.skplanet.commute.controllers.MyApplication;

@SuppressLint("DefaultLocale")
public class Actions {

	private static final float DEFAULT_HDIP_DENSITY_SCALE = 1.5f;

	public static int PixelFromDP(int DP) {
		float scale = MyApplication.getAppContext().getResources().getDisplayMetrics().density;
		return (int) (DP / scale * DEFAULT_HDIP_DENSITY_SCALE);
	}

	public static int DPFromPixel(int pixel) {

		float scale = MyApplication.getAppContext().getResources().getDisplayMetrics().density;
		return (int) (pixel / DEFAULT_HDIP_DENSITY_SCALE * scale);
	}

	public static String setTime(String timeValue) {
		int timeNum = Integer.parseInt(timeValue);
		String retValue = "";
		if (timeNum / 60 != 0) retValue = String.format("%d분 %d초 남음", timeNum / 60, timeNum % 60);
		else retValue = String.format("%d초 남음", timeNum % 60);
		return retValue;
	}

	public static String setBusTypeStr(String busType) {
		// (1:공항, 3:간선, 4:지선, 5:순환, 6:광역, 7:인천, 8:경기, 9:폐지, 0:공용)
		String retValue = "경기";
		if (busType != null) {
			switch (busType.charAt(0)) {
			case '1':
				retValue = "공항";
				break;
			case '3':
				retValue = "간선";
				break;
			case '4':
				retValue = "지선";
				break;
			case '5':
				retValue = "순환";
				break;
			case '6':
				retValue = "광역";
				break;
			case '7':
				retValue = "인천";
				break;
			case '8':
				retValue = "경기";
				break;

			}
		}
		return retValue;
	}

	public static String setBusTypeColor(String busType) {
		// (1:공항, 3:간선, 4:지선, 5:순환, 6:광역, 7:인천, 8:경기, 9:폐지, 0:공용)
		String retValue = "#7C2BB3"; // 124, 43, 179
		if (busType != null) {
			switch (busType.charAt(0)) {
			case '1':
				retValue = "#67C0E6"; // 103,192,230
				break;
			case '3':
				retValue = "#3673DE"; // 54, 115, 222
				break;
			case '4':
				retValue = "#81B332"; // 129,179,50
				break;
			case '5':
				retValue = "#FFAE00"; // 255,174,0
				break;
			case '6':
				retValue = "#D43F00"; // 212, 63, 0
				break;
			case '7':
				retValue = "#7C2BB3"; // 124, 43, 179
				break;
			case '8':
				retValue = "#000000"; // 0,0,0
				break;

			}
		}
		return retValue;
	}

	public static String setBusTime(String busTime) {
		String retValue = busTime.substring(8, 10) + ":" + busTime.substring(10, 12);
		return retValue;
	}

	public static String setBusStopStr(String busStopStr) {
		String retValue = "";
		if (busStopStr.length() > 5) retValue = busStopStr.substring(0, 5) + "...";
		else retValue = busStopStr;
		return retValue;
	}
	
	

}
